package com.qianbao.components.svresut;

import com.qianbao.components.excepion.ExceptionEnum;

import java.util.Collections;

public class Result {

    private int code;

    private Object data;

    private String message;

    public Result() {
    }

    public static Result success(Object data){
        Result result = new Result();
        result.code = ExceptionEnum.Request_Success.getCode();
        result.message = ExceptionEnum.Request_Success.getMessage();
        result.data = data;
        return result;
    }

    public static Result success(int code,String message,Object data){
        Result result = new Result();
        result.code = code;
        result.message = message;
        result.data = data;
        return result;
    }


    public static Result fail(int code,String message){
        Result result = new Result();
        result.code = code;
        result.message = message;
        result.data = Collections.emptyMap();
        return result;
    }

    public static Result fail(int code,String message,Object data){
        Result result = new Result();
        result.code = code;
        result.message = message;
        result.data = data;
        return result;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
